<template>
  <div :class="{classDetail:true,[$store.getters.isDay?'day':'night']:true}">
    <Header></Header>
    <div class="container">
      <div class="class_name">
        <span>{{ $route.params.name }}</span>
      </div>
      <div class="post">
        <div class="article" v-for="(item, index) in articleList" :key="index">
          <span class="title">{{ item.title }}</span>
          <!-- <span v-html="item.body_html"></span> -->
          <div class="time">
            <i class="iconfont icon-time"></i>
            <span>{{ item.create_time }}</span>
          </div>
          <div class="mask" @click="goDetail(item._id)">点击进入</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Header from '../../components/Header.vue'
export default {
  name: "classdetail",
  data() {
    return {
      articleList: [],
    };
  },
  components: {
    Header,
  },
  created() {
    this.getClassArticle();
  },
  methods: {
    getClassArticle() {
      // console.log(this.$route.params);

      this.$axios
        .get(`/vueShow/article/class/${this.$route.params.name}`)
        .then((res) => {
          console.log(res.data);
          this.articleList = res.data.data;
        })
        .catch((err) => console.log(err));
    },
    goDetail(id) {
      this.$router.push(`/article/${id}`);
    },
  },
};
</script>

<style scoped lang="scss">
.classDetail {
  width: 100%;
  min-height: 100vh;
  overflow: hidden;
  background-color: #339999;
  transition:all 0.5s ease-in-out;
  .container {
    width: 100%;
    height: 100%;
    padding-top: 105px;
    font-family: Consolas, Monaco, "Segoe UI", Helvetica, Arial, sans-serif,
      "Apple Color Emoji", "Segoe UI Emoji";
    .class_name {
      width: 90%;
      margin: 0 auto;
      padding: 5px 10px;
      span {
        // display: block;
        // width: 163px;
        // height: 66px;
        padding:10px;
        margin:10px 0;
        background-color: #fff;
        border-radius: 10px;
        text-align: center;
        font-size: 33px;
        color: skyblue;
        font-weight: 600;
      }
    }
    .post {
      width: 90%;
      margin: 10px auto 15px;
      padding: 5px 10px;
      background-color: #fff;
      box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.4);
      border-radius: 10px;
      display: flex;
      justify-content: left;
      flex-wrap: wrap;

      .article {
        width: 260px;
        height: 100px;
        position: relative;
        // flex:1;
        background-color: #339999;
        box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.4);
        padding: 10px;
        margin: 10px 5px;
        border-radius: 10px;
        overflow: hidden;
        .title {
          display: block;
          width: 100%;
          font-weight: 600;
          font-size: 22px;
          position: absolute;
          top: 20px;
        }
        .time {
          width: 100%;
          font-size: 15px;
          color: #000;

          position: absolute;
          bottom: 10px;
        }
        .mask {
          position: absolute;
          left: -100%;
          top: calc(50% - 15px);
          width: 100%;
          height: 30px;
          background-color: skyblue;
          text-align: center;
          line-height: 30px;
          font-size: 14px;
          font-weight: 600;
          color: #339999;
          transition: all 0.3s ease-in-out;
          cursor: pointer;
        }
      }
    }
    // .article::after {
    //   position: absolute;
    //   left: -100%;
    //   top: calc(50% - 15px);
    //   content: "点击进入";
    //   width: 100%;
    //   height: 30px;
    //   background-color: skyblue;
    //   transition: all 0.3s ease-in-out;
    //   text-align: center;
    //   line-height: 30px;
    //   font-size: 14px;
    //   font-weight: 600;
    //   color: #339999;
    // }
    .article:hover {
      .mask {
        left: 0;
      }
    }
  }
}
</style>